#include <stdio.h>  
#include <string.h>  
  
void splitstr(char *buf, char a) {  
    int len = strlen(buf); // 在循环外部计算字符串长度  
    int temp = 0;  
    for (int i = 0; i <= len; i++)
    {  
        if (buf[i] == a || i == len) 
        {  
            for (int j = temp; j < i; j++) 
            {  
                printf("%c", buf[j]);  
            }  
            
            temp = i + 1;  
        }  
    }  
}  
  
int main() 
{  
    char ar[] = {"hello world gec ting"};  
    char a = ' ';  
    splitstr(ar, a);  
    return 0;  
}